import  os
import  sys
import  tty, termios
#fd = sys.stdin.fileno()
#old_settings = termios.tcgetattr(fd)
#try :
#    tty.setraw( fd )
#    ch = sys.stdin.read( 1 )
#    print ch
#finally :
#    termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)

fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
while True:
    tty.setraw(fd)
    ch = sys.stdin.read(1)
    #print type(ch),len(ch)
    if ord(ch[0]) == (ord('a') & 0x1f):
        print 'ctrl+a',ord(ch[0]),
    elif ord(ch[0]) == (ord('x') & 0x1f):
        print 'ctrl+x',ord(ch[0]),
    elif ord(ch[0]) == (ord('z') & 0x1f):
        print 'ctrl+z',ord(ch[0]),
    elif ord(ch[0]) == (ord('q') & 0x1f):
        print 'ctrl+q',ord(ch[0]),
        break; 
    else:
        print '\b%c'%ch[0],

termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
